﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LogicCircuit;
namespace LogicCircuit
{

    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
            comboBox1.SelectedIndex = 0;

        }
        LogicCircuit ForTestingOne = new LogicCircuit();
        private void button2_Click(object sender, EventArgs e)
        {

            ForTestingOne.AddElement(1, 1, 0); //Add source
            ForTestingOne.AddElement(2, 2, 3); //Add NOT
            ForTestingOne.AddElement(3, 3, 4); //Add sink

            ForTestingOne.AddConnection(1, 1, 2, 2);
            ForTestingOne.AddConnection(2, 2, 3, 3);
            ForTestingOne.Calculate();

        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {

        }

        private void btn_addElement_Click(object sender, EventArgs e)
        {
            int x = Convert.ToInt32(txtBox_elementX.Text);
            int y = Convert.ToInt32(txtBox_elementY.Text);
            int type = comboBox1.SelectedIndex;


            ForTestingOne.AddElement(x, y, type);
            ForTestingOne.RefreshListBoxes(list_elements, list_connections);
        }
        private void btn_addConnection_Click(object sender, EventArgs e)
        {
            int sX = Convert.ToInt32(txtBox_supplierX.Text);
            int sY = Convert.ToInt32(txtBox_supplierY.Text);
            int tX = Convert.ToInt32(txtBox_targetX.Text);
            int tY = Convert.ToInt32(txtBox_targetY.Text);

            ForTestingOne.AddConnection(sX, sY, tX, tY);
            ForTestingOne.RefreshListBoxes(list_elements, list_connections);
        }
        private void MainForm_Load(object sender, EventArgs e)
        {

        }

        private void txtBox_elementY_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_elementX.Text.Length > 0 && txtBox_elementY.Text.Length > 0)
                btn_addElement.Enabled = true;
        }

        private void txtBox_elementX_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_elementX.Text.Length > 0 && txtBox_elementY.Text.Length > 0)
                btn_addElement.Enabled = true;
        }

        private void txtBox_supplierX_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_supplierX.Text.Length > 0 && txtBox_supplierY.Text.Length > 0
                && txtBox_targetX.Text.Length > 0 && txtBox_targetY.Text.Length > 0)
                btn_addConnection.Enabled = true;
        }

        private void txtBox_supplierY_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_supplierX.Text.Length > 0 && txtBox_supplierY.Text.Length > 0
                && txtBox_targetX.Text.Length > 0 && txtBox_targetY.Text.Length > 0)
                btn_addConnection.Enabled = true;
        }

        private void txtBox_targetX_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_supplierX.Text.Length > 0 && txtBox_supplierY.Text.Length > 0
                && txtBox_targetX.Text.Length > 0 && txtBox_targetY.Text.Length > 0)
                btn_addConnection.Enabled = true;
        }

        private void txtBox_targetY_TextChanged(object sender, EventArgs e)
        {
            if (txtBox_supplierX.Text.Length > 0 && txtBox_supplierY.Text.Length > 0
                && txtBox_targetX.Text.Length > 0 && txtBox_targetY.Text.Length > 0)
                btn_addConnection.Enabled = true;
        }


    }
}
